import { Routes, RouterModule } from '@angular/router'
import { NgModule } from '@angular/core'
import { LoginComponent } from './views/login/login.component'
import { NotFoundPageComponent } from './views/error-page/404/404.component'
import { PubsPageComponent } from './views/publications/pubs-page/pubs-page.component'
import { HomeComponent } from './views/home/home.component'
import { PubCreateComponent } from './views/publications/mg/create/pub-create.component'
import { OrgTreeComponent } from './views/org/org-tree/org-tree.component'
import { UserInfoComponent } from './views/system/user-info/user-info.component'
import { RoleAuthMapComponent } from './views/system/role-auth-map/role-auth-map.component'
import { WelcomeComponent } from './views/home/welcom/welcome.component'

const homeRouters: Routes = [
  { outlet: 'mainPanel', path: '', component: WelcomeComponent },
  { outlet: 'mainPanel', path: 'pub/page', component: PubsPageComponent },
  { outlet: 'mainPanel', path: 'org/info', component: PubCreateComponent },
  { outlet: 'mainPanel', path: 'org/orgTree', component: OrgTreeComponent },
  { outlet: 'mainPanel', path: 'org/member', component: PubCreateComponent },
  { outlet: 'mainPanel', path: 'sys/userInfo', component: UserInfoComponent },
  { outlet: 'mainPanel', path: 'mg/org', component: PubCreateComponent },
  { outlet: 'mainPanel', path: 'mg/pub/create', component: PubCreateComponent },
  { outlet: 'mainPanel', path: 'mg/sys/roleAuthMap', component: RoleAuthMapComponent },
  { outlet: 'mainPanel', path: '**', component: NotFoundPageComponent },
]

const appRouters: Routes = [
  { path: '', redirectTo: 'login', pathMatch: 'full' },
  { path: 'login', component: LoginComponent },
  {
    path: 'home', component: HomeComponent,
    children: homeRouters
  },
  { path: '**', component: NotFoundPageComponent },
]
@NgModule({
  imports: [
    RouterModule.forRoot(
      appRouters,
      {
        scrollPositionRestoration: 'enabled'
      }
    )
  ],
  exports: [RouterModule]
})
export class AppRoutingModule { }
